import axios from '@/utils/request';

/**
 * 根据当前公司下所有仓库
 */
 export async function GetAllWarehouse() {
    const res = await axios.post('/Warehouse/QueryWarehouseAll');
    if (res.data.code === 200) {
        return res.data.data;
    }
    return Promise.reject(new Error(res.data.msg));
}

/**
 * 根据当前公司下所有仓库
 */
export async function QueryWarehousePageList(params) {
    const res = await axios.post('/Warehouse/QueryWarehousePageList',params);
    if (res.data.code === 200) {
        return res.data.data;
    }
    return Promise.reject(new Error(res.data.msg));
}


/**
 * 添加仓库
 */
 export async function AddWarehouse(params) {
    const res = await axios.post('/Warehouse/AddWarehouse',params);
    if (res.data.code === 200) {
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
}

/**
 * 修改仓库
 */
 export async function UpdateWarehouse(params) {
    const res = await axios.post('/Warehouse/UpdateWarehouse',params);
    if (res.data.code === 200) {
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
}


/**
 * 删除仓库
 */
 export async function DeleteWarehouse(id) {
    const res = await axios.post('/Warehouse/DeleteWarehouse?id='+id);
    if (res.data.code === 200) {
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
}
/**
 * 设置默认仓库
 */
export async function SetDefaultWarehouse(id) {
    const res = await axios.post('/Warehouse/SetDefaultWarehouse?id='+id);
    if (res.data.code === 200) {
        return res.data.msg;
    }else{
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
}

/**
 * 根据Id查询仓库
 */
 export async function QueryCurrentWarehouseById(id) {
    const res = await axios.get('/Warehouse/GetModelById/'+id);
    if (res.data.code === 200) {
        return res.data.data;
    }
    return Promise.reject(new Error(res.data.msg));
}

 /**
  * 修改仓库状态信息
  */
 export async function UpdateStatus(params) {
    const res = await axios.post('/Warehouse/UpdateStatus',params);
    if (res.data.code === 200) {
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
  }

